package com.louis.iread.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.louis.iread.event.EventType;
import com.louis.iread.event.ReadEvent;

import org.greenrobot.eventbus.EventBus;

public class BatteryReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        int current = intent.getExtras().getInt("level");// 获得当前电量
        int total = intent.getExtras().getInt("scale");// 获得总电量
        int percent = current * 100 / total;
        EventBus.getDefault().post(new ReadEvent(EventType.BATTERY_NTF, percent));
    }
}
